# -*- coding: utf-8 -*-
# @File     : validators.py
# @Author   : bingjia
# @Time     : 2020/8/4 13:36
# @Desc     : 登陆注册数据验证

from ..base.api import serializers


class RegisterValidator(serializers.Serializer):
    """
    注册验证
    """
    full_name = serializers.CharField(max_length=256)
    email = serializers.EmailField(max_length=255)
    username = serializers.CharField(max_length=255)
    password = serializers.CharField(min_length=6)

    # def validate_username(self, attrs, source):
    #     """
    #     验证用户名
    #     :param attrs:
    #     :param source:
    #     :return:
    #     """
    #     value = attrs[source]
    #     validator = core_validators.RegexValidator(re.compile('^[\w.-]+$'), _("invalid username"), "invalid")
    #
    #     try:
    #         validator(value)
    #     except ValidationError:
    #         raise ValidationError(_("Required. 255 characters or fewer. Letters, numbers "
    #                                 "and /./-/_ characters'"))
    #     return attrs


